- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
Gmail - Adding checks for service account key #15817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| The latest updates on your projects. Learn more about Vercel for Git ↗︎ | 
| WalkthroughThis pull request updates version numbers and refines error handling in the Gmail component. The package version in  Changes
 Sequence Diagram(s)sequenceDiagram
  participant S as Email Source
  participant G as getServiceAccountKeyJson()
  S->>G: Request service account key JSON
  alt Valid JSON provided
    G-->>S: Return parsed JSON
  else Invalid JSON or missing configuration
    G-->>S: Throw ConfigurationError
  end
Possibly related PRs
 Suggested labels
 Suggested reviewers
 Poem
 Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
 components/gmail/sources/new-email-received/new-email-received.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs ✨ Finishing Touches
 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit: 
 Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
 Other keywords and placeholders
 CodeRabbit Configuration File ( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/gmail/sources/new-email-received/new-email-received.mjs (1)
320-326: Excellent addition of robust error handling.The new
getServiceAccountKeyJson()method properly wraps the JSON parsing operation with a try-catch block and provides a clear error message that explains what went wrong. This is a significant improvement for error handling and user experience.A small optimization could be to cache the parsed result to avoid parsing the same JSON multiple times during execution, but this is a minor suggestion.
getServiceAccountKeyJson() { + if (this._parsedServiceAccountKey) { + return this._parsedServiceAccountKey; + } try { - return JSON.parse(this.serviceAccountKeyJson); + this._parsedServiceAccountKey = JSON.parse(this.serviceAccountKeyJson); + return this._parsedServiceAccountKey; } catch (err) { throw new ConfigurationError(`Error parsing \`Service Account Key JSON\`. Ensure its contents are valid JSON. \`${err}\``); } },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
- pnpm-lock.yamlis excluded by- !**/pnpm-lock.yaml
📒 Files selected for processing (2)
- components/gmail/package.json(1 hunks)
- components/gmail/sources/new-email-received/new-email-received.mjs(4 hunks)
✅ Files skipped from review due to trivial changes (1)
- components/gmail/package.json
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
🔇 Additional comments (4)
components/gmail/sources/new-email-received/new-email-received.mjs (4)
18-18: Version appropriately incremented.The version number has been updated from 0.1.10 to 0.1.11 to reflect the service account key validation enhancements.
169-169: Good error handling improvement.Replacing direct JSON parsing with the new
getServiceAccountKeyJson()method enhances error handling and provides better user feedback when there are issues with the service account key JSON format.
328-332: Critical validation added for service account key.This check ensures that the service account key is available before attempting to use it, preventing cryptic errors during execution. The error message is clear and provides guidance on how to resolve the issue.
345-346: Minor formatting improvement.Adding a blank line improves code readability by separating logical sections.
| Replaced by #15820 | 
Closes #15809
Summary by CodeRabbit